[![Build Status](https://img.shields.io/travis/google/eddystone.svg?style=flat-square)](https://travis-ci.org/google/eddystone)

# Eddystone Advertising Library

The Eddystone Advertising Library abstracts low level concepts of the Eddystone
protocol and wraps existing Advertising APIs so that developers don't have to
worry about these low level details. The library exposes simple functions that
developers can use to advertise a Valid Eddystone packet from their device.

**NOTE** Currently only ChromeOS is supported.  

## Usage
The Eddystone Advertising Library creates `window.eddystone` of type
[`Eddystone`](#eddystone)

To advertise a url:
**Example**
```js
let registered_adv;
eddystone.registerAdvertisement({
  type: 'url',
  url: 'https://example.com',
  advertisedTxPower: -20
}).then(advertisement => {
  registered_adv = advertisement;
  console.log('Advertising: ' + advertisement.url)
}).catch(error => console.log(error.message));
```

To stop advertising:
**Example**
```js
registered_adv.unregisterAdvertisement().then(() => {
  console.log('Advertisement unregistered successfully.');
}).catch(error => console.log(error.message));
```
Or if you have multiple advertisements:
```js
eddystone.advertisements.forEach(advertisement => {
  advertisement.unregisterAdvertisement()
    .then(() => console.log('Unregistered successfully'))
    .catch(error => console.log('Couldn\'t unregister the advertisement: ' + error.message));
});
```
## API
{{>main}}
